﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Billing.WindowsBase
{
    public enum eOpenMode
    {
        New,
        Edit,
        CheckInfo
    }

    public partial class BaseEditor : Form
    {
        #region Constructors
        internal BaseEditor()
        {
            InitializeComponent();
        }
        public BaseEditor(eOpenMode OpenMode)
            : this()
        {
            this.openMode = OpenMode;
        }
        public BaseEditor(BaseList parent, eOpenMode OpenMode)
            : this(OpenMode)
        {
            this.Parent = parent;
        }

        #endregion
        private BaseList Parent;

        #region Public Properties
        private eOpenMode openMode;
        public eOpenMode OpenMode
        {
            get { return openMode; }
            set { openMode = value; }
        }

        public object DataObject
        {
            get { return this.bsEditor.DataSource; }
            set { this.bsEditor.DataSource = value; }
        }

        private object mGroup_ID;
        public object Group_ID
        {
            get { return mGroup_ID; }
            set { mGroup_ID = value; }
        }

        private object mGroupParent_ID;
        public object GroupParent_ID
        {
            get { return mGroupParent_ID; }
            set { mGroupParent_ID = value; }
        }
        private bool allowSave = true;
        public bool AllowSave
        {
            get { return allowSave; }
            set
            {
                allowSave = value;
                this.RefreshOperation();
            }
        }
        private void RefreshOperation()
        {
            //      if (this.btnAdd.Visible != this.allowAdd)
            this.btnSave.Visible = this.allowSave;

        }
        bool panelTopVisible = true;
        [DefaultValue(true)]
        public bool PanelTopVisible
        {
            get
            { return this.panelTopVisible; }
            set
            {
                panelTopVisible = value;
                this.pnlTop.Visible = panelTopVisible;
            }
        }
        #endregion

        #region Button Events
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.onSave();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.onClose();
        }
        #endregion

        #region virtual methods
        protected virtual void onSave()
        {
            if (this.Parent != null)
                this.Parent.Refresh();
        }
        protected virtual void onClose()
        {
            this.Close();
        }
        protected virtual void onDataLoad()
        { }
        protected virtual void onSetDataBindings()
        { }
        protected virtual void onSetDefaults()
        {
        }
        #endregion

        #region Overrides
        protected override void OnLoad(EventArgs e)
        {
            //new UserRightsManager().SetupProperties(this);

            base.OnLoad(e);
            this.onDataLoad();

            this.onSetDataBindings();

        }
        #endregion

        private void tbConteiner_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
        {

        }
    }
}
